package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.empployee.EmployeeLoginDTO;
import com.sky.dto.empployee.EmployeePageQueryDTO;
import com.sky.dto.empployee.EmployeeUpdatePassWordDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author 褚金龙
 * @Date 2024/8/28 17:44
 */
@Mapper
public interface EmployeeMapper {
    /**
     * 验证账号密码
     * @param employeeLoginDTO
     * @return
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")// 会自动将生成的主键值封装到EmployeeLoginDTO对象中
    @Select("select *from employee where username= #{username} or password=#{password} " )
    public Employee login(EmployeeLoginDTO employeeLoginDTO);

    /**
     * 添加员工
     * @param employee
     */
    @AutoFill(value = OperationType.INSERT)
    public void addEmp(Employee employee);

    /**
     * 查询员工
     * @param
     */

    @Select("select *from employee order by update_time desc ")
     public List<Employee> queryEmp();

    /**
     * 分页查询
     * @return
     */

       public Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 根据id查询员工
     * @param id
     * @return
     */
  @Select("select*from employee where id=#{id}")
    Employee select(Long id);

    /**
     * 修改员工
     * @param employee
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateEmp(Employee employee);

    /**
     * 修改员工状态
     * @param status
     * @param id
     */
    @AutoFill(value = OperationType.UPDATE)
    void statusEmp(Integer status, Integer id);

    /**
     * 删除员工
     * @param id
     */
    @Delete("delete from employee  where id=#{id}")
      void deleteEmp(Integer id);


    /**
     * 修改登录密码
     * @param employeeUpdatePassWordDTO
     */

    @AutoFill(value = OperationType.UPDATE)
 void updatePassWord(EmployeeUpdatePassWordDTO employeeUpdatePassWordDTO);
}
